<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!doctype html>
<html class="no-js">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>沃店</title>
    <!-- Set render engine for 360 browser -->
    <meta name="renderer" content="webkit">
    <!-- No Baidu Siteapp-->
    <meta http-equiv="Cache-Control" content="no-siteapp"/>

    <!-- Add to homescreen for Chrome on Android -->
    <meta name="mobile-web-app-capable" content="yes">

    <!-- Add to homescreen for Safari on iOS -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>

    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/amazeui.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/app.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/index.css">
    <script src="${pageContext.request.contextPath}/assets/js/jquery.min.js"></script>

    <script type="text/javascript">

        function onBridgeReady() {
            WeixinJSBridge.invoke(
                'getBrandWCPayRequest', {
                    "appId": '${signMap.appId}',     //公众号名称，由商户传入
                    "timeStamp": '${signMap.timeStamp}',         //时间戳，自1970年以来的秒数
                    "nonceStr": '${signMap.nonceStr}', //随机串
                    "package": '${prepay}',
                    "signType": '${signMap.signType}',         //微信签名方式：
                    "paySign": '${signMap.paySign}' //微信签名
                },
                function (res) {
                    if (res.err_msg == "get_brand_wcpay_request:ok") {

                        setInterval(function () {

                            var type = $("#type").val();
                            if (type == 1) {
                                window.location.href = "${pageContext.request.contextPath}/clientHome/userorderlist";
                            } else if (type == 2) {
                                window.location.href = "${pageContext.request.contextPath}/clientHome/goRechargeList";
                            } else if (type == 3) {
                                window.location.href = "${pageContext.request.contextPath}/clientHome/goGoodsOrderList";
                            } else {
                                window.location.href = "${pageContext.request.contextPath}/clientHome/userInfo";
                            }

                        }, 2000);
                        layer.msg('支付成功，2秒后返回订单列表！');
                    }     // 使用以上方式判断前端返回,微信团队郑重提示：res.err_msg将在用户支付成功后返回    ok，但并不保证它绝对可靠。
                }
            );
        }
        if (typeof WeixinJSBridge == "undefined") {
            if (document.addEventListener) {
                document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
            } else if (document.attachEvent) {
                document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
            }
        } else {
            onBridgeReady();
        }

        $(function () {
            onBridgeReady();
        });

    </script>

    <!--必要样式-->
    <style type="text/css">
        body {
            background-color: #EFEFEF;
        }

    </style>
</head>

<body>
<header data-am-widget="header" class="am-header am-header-default am-header-fixed">
    <div class="am-header-left am-header-nav">
    </div>
    <h1 class="am-header-title">
        <a href="#title-link" class="">
            收银台
        </a>
    </h1>
    <div class="am-header-right am-header-nav">
        <%--<a href="#right-link" class="">--%>
        <%--<i class="am-header-icon am-icon-home"></i>--%>
        <%--</a>--%>
    </div>
</header>

<div class="am-g whiteBg" style="margin-top:49px;padding:15px 0;">
    <div class="am-u-sm-12" align="center">
        <span>支付金额</span><br>
        <span style="font-size:24px;font-weight: bold;">￥${money}元</span><br>
        <input id="type" type="hidden" value="${type}">
        <span style="font-size:14px;color:#999;">产品名称：${name}</span>

    </div>
</div>
<div class="am-u-sm-12" style="margin-top: 50px;">
    <button onclick="onBridgeReady()"
            style="border:none;border-radius:5px;width: 100%;background-color: #00B83F;padding-top:10px;padding-bottom: 10px;color:#fff; ">
        立即支付
    </button>
</div>
<!--[if (gte IE 9)|!(IE)]><!-->

<script src="${pageContext.request.contextPath}/assets/js/amazeui.min.js"></script>
<script type="text/javascript">


</script>
</body>

</html>
